<?php

namespace app\logic\single;

use app\logic\model\user\UserMusicLogicModel;
use app\logic\model\user\UserScoreLogicModel;

class UserScoreSingle
{
    private static $inc;
    /**
     * @var UserMusicLogicModel
     */
    private $userScoreModel;

    private function __clone(){

    }

    public static function getInstance(){
        if(is_null(self::$inc)){
            self::$inc = new self();
        }
        return self::$inc;
    }
    private function __construct()
    {
        $this->userScoreModel = new UserScoreLogicModel();
    }

    public function createLog($user_id,$type,$price =0,$source = 1,$order_id=0,$remark=''){
        $price = $type ==1 ?$price :-$price;
        return $this->userScoreModel->save([
            'user_id'=>$user_id,
            'type'=>$type,
            'price'=>$price,
            'source'=>$source,
            'order_id'=>$order_id,
            'remark'=>$remark,
        ]);
    }
}